package 
{
	import ericXie.com.controller.MainController;
	import ericXie.com.events.LoadElementEvent;
	import ericXie.com.events.LoadLibFinshEvent;
	import ericXie.com.model.MainModel;
	import ericXie.com.view.RouletteView;
	import flash.display.MovieClip;
	import flash.display.Sprite;
	import flash.events.Event;
	
	/**
	 * ...转盘效果
	 * @author EricXie
	 */
	[SWF(width="445",height="450")]
	public class Main extends Sprite 
	{
		private var mainCtrl:MainController = new MainController();
		private var _model:MainModel = MainModel.getInstance();
		private var rouletteView:RouletteView;
		public function Main():void 
		{
			if (stage) init();
			else addEventListener(Event.ADDED_TO_STAGE, init);
		}
		
		private function init(e:Event = null):void 
		{			
			removeEventListener(Event.ADDED_TO_STAGE, init);
			// entry point
			_model.mainApp = this;
			new LoadElementEvent(LoadElementEvent.LIB_PATH).dispatch();
			_model.addEventListener(LoadLibFinshEvent.EVENT_ID, finshElementHandler);
		}
		
		private function finshElementHandler(e:LoadLibFinshEvent):void 
		{
		
			rouletteView = new RouletteView();
			this.addChild(rouletteView);
			_model.initResidueNum = this.loaderInfo.parameters["initResidueNum"];
		}
		
	}
	
}